import { IPSAppCounter } from './ipsapp-counter';
import { IPSAppDEAction } from '../dataentity/ipsapp-deaction';
import { IPSAppDEDataSet } from '../dataentity/ipsapp-dedata-set';
import { IPSAppDataEntity } from '../dataentity/ipsapp-data-entity';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';
import { IPSSysSFPlugin } from '../../res/ipssys-sfplugin';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSAppCounterImpl extends PSModelObjectImpl implements IPSAppCounter {
  get codeName(): string {
    return this.M.codeName;
  }

  get counterData(): string {
    return this.M.counterData;
  }

  get counterData2(): string {
    return this.M.counterData2;
  }

  get counterType(): string {
    return this.M.counterType;
  }

  get customCond(): string {
    return this.M.customCond;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  protected getpsappdeaction: IPSAppDEAction | null = null;

  getGetPSAppDEAction(): IPSAppDEAction | null {
    if (this.getpsappdeaction != null) return this.getpsappdeaction;
    const value = this.M.getGetPSAppDEAction;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.getpsappdeaction = ipsappdataentity.findPSAppDEAction(value);
    }
    return this.getpsappdeaction;
  }

  get getPSAppDEAction(): IPSAppDEAction | null {
    return this.getGetPSAppDEAction();
  }

  getGetPSAppDEActionMust(): IPSAppDEAction {
    const value = this.getGetPSAppDEAction();
    if (value == null) {
      throw new Error('未指定计算应用实体行为');
    }
    return value;
  }

  protected getpsappdedataset: IPSAppDEDataSet | null = null;

  getGetPSAppDEDataSet(): IPSAppDEDataSet | null {
    if (this.getpsappdedataset != null) return this.getpsappdedataset;
    const value = this.M.getGetPSAppDEDataSet;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.getpsappdedataset = ipsappdataentity.findPSAppDEDataSet(value);
    }
    return this.getpsappdedataset;
  }

  get getPSAppDEDataSet(): IPSAppDEDataSet | null {
    return this.getGetPSAppDEDataSet();
  }

  getGetPSAppDEDataSetMust(): IPSAppDEDataSet {
    const value = this.getGetPSAppDEDataSet();
    if (value == null) {
      throw new Error('未指定计算应用实体数据集');
    }
    return value;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  get orderValue(): number {
    return this.M.orderValue != null ? this.M.orderValue : 99999;
  }

  protected psappdataentity: IPSAppDataEntity | null = null;

  getPSAppDataEntity(): IPSAppDataEntity | null {
    if (this.psappdataentity != null) return this.psappdataentity;
    const value = this.M.getPSAppDataEntity;
    if (value == null) {
      return null;
    }
    this.psappdataentity = this.getPSModel4('app.dataentity.IPSAppDataEntity', value, 'getPSAppDataEntity') as IPSAppDataEntity;
    return this.psappdataentity;
  }

  get psAppDataEntity(): IPSAppDataEntity | null {
    return this.getPSAppDataEntity();
  }

  getPSAppDataEntityMust(): IPSAppDataEntity {
    const value = this.getPSAppDataEntity();
    if (value == null) {
      throw new Error('未指定应用实体对象');
    }
    return value;
  }

  get psCounterId(): string {
    return this.M.getPSCounterId;
  }

  getPSCounterId(): string {
    return this.M.getPSCounterId;
  }

  protected pssyspfplugin: IPSSysPFPlugin | null = null;

  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    if (this.pssyspfplugin != null) return this.pssyspfplugin;
    const value = this.M.getPSSysPFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyspfplugin = this.getPSModel4('res.IPSSysPFPlugin', value, 'getPSSysPFPlugin') as IPSSysPFPlugin;
    return this.pssyspfplugin;
  }

  get psSysPFPlugin(): IPSSysPFPlugin | null {
    return this.getPSSysPFPlugin();
  }

  getPSSysPFPluginMust(): IPSSysPFPlugin {
    const value = this.getPSSysPFPlugin();
    if (value == null) {
      throw new Error('未指定前端模板插件对象');
    }
    return value;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后端模板插件对象');
    }
    return value;
  }

  get timer(): number {
    return this.M.timer != null ? this.M.timer : 0;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSAppCounterImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'IPSModelSortable' || cls == 'app.control.IPSAppCounter' || cls == 'control.counter.IPSSysCounter') return true;
    return super.instanceof(cls);
  }
}
